package com.jstyle.jclife.NetWork.api;

import com.jstyle.jclife.model.AppUpdateData;
import com.jstyle.jclife.model.NetResultData;
import com.jstyle.jclife.model.RankData;
import com.jstyle.jclife.model.SosContact;
import com.jstyle.jclife.model.UpdateData;
import com.jstyle.jclife.model.UploadData;
import com.jstyle.jclife.model.UploadGpsData;
import com.jstyle.jclife.model.UserInfoQuery;
//import com.jstyle.gps.model.UpdateData;
//import com.jstyle.gps.model.UserInfoQuery;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Streaming;
import retrofit2.http.Url;


/**
 * Created by Administrator on 2017/3/24.
 */

public interface JstyleApi {
    @GET("sms/send")
    Observable<NetResultData> getSmsCode(@QueryMap Map<String, Object> userMap);

    @GET("sms/sendEmail")
    Observable<NetResultData> getEmailCode(@QueryMap Map<String, Object> userMap);

    @FormUrlEncoded
    @POST("user/register")
    Observable<NetResultData> register(@FieldMap Map<String, Object> userMap);

    @FormUrlEncoded
    @POST("user/login")
    Observable<NetResultData<String>> login(@FieldMap Map<String, Object> userMap);

    @FormUrlEncoded
    @POST("user/retrieve")
    Observable<NetResultData> findPassword(@FieldMap Map<String, Object> userMap);

    @FormUrlEncoded
    @POST("user/loginAuth")
    Observable<NetResultData<String>> loginAuth(@FieldMap Map<String, Object> userMap);

    @GET("user/validateToken")
    Observable<NetResultData> getUserId(@Query("query") boolean query, @Query("token") String token);

    @FormUrlEncoded
    @POST("user/updatePwd")
    Observable<NetResultData> changePsd(@FieldMap Map<String, Object> maps);


    @POST("https://app.le-young.com/jcloud/jclifedata/data/save")
    Observable<NetResultData> uploadData(@Body UploadData uploadData);

    @POST("https://app.le-young.com/jcloud/jclifedata/data/saveGps")
    Observable<NetResultData> uploadGpsData(@Body UploadGpsData uploadData);

    @FormUrlEncoded
    @POST("user/updatePhone")
    Observable<NetResultData> changePhone(@FieldMap Map<String, Object> maps);

    @FormUrlEncoded
    @POST("https://api.le-young.com/intlsso/opinion/save")
    Observable<NetResultData> feedBack(@FieldMap Map<String, String> maps);

    @FormUrlEncoded
    @POST("https://app.le-young.com/jcloud/usercenter/applog/save")
    Observable<NetResultData> uploadOtaLog(@FieldMap Map<String, String> maps);

    @GET("http://api.le-young.com/device/firmware/v2/update")
    Observable<UpdateData> queryDeviceVersion(@QueryMap Map<String, String> versionMap);

    @GET("https://api.le-young.com/device/resource/updategps?type=1755")
    Observable<NetResultData> downLoadGpsFile();


//    @GET("https://api.le-young.com/sleep/user/query")
//    Observable<NetResultData<UserInfoQuery>>getUserInfo(@Query("token") String token);

    @Streaming
    @GET
    Observable<ResponseBody> downloadPath(@Url String url);

    @Streaming
    @GET
    Observable<ResponseBody> downloadIcon(@Url String url);

    @GET("http://api.le-young.com/device/appupdate/query")
    Observable<AppUpdateData> queryAppVersion(@QueryMap Map<String, String> versionMap);

    /**
     * 领英分享的图片上传
     *
     * @param file
     * @param maps
     * @return
     */
    @Multipart
    @POST("share/upImg")
    Observable<NetResultData<String>> updateImage(@Part MultipartBody.Part file, @PartMap Map<String, RequestBody> maps);

    @GET("https://api.le-young.com/intlsso/userInfo/query")
    Observable<NetResultData<UserInfoQuery>> getUserInfo(@Query("uid") String token);

    @FormUrlEncoded
    @POST("https://api.le-young.com/intlsso/userInfo/save")
    Observable<NetResultData<String>> saveUserInfo(@FieldMap Map<String, String> userInfo);

    @GET("http://api.le-young.com/pushServer/api/sos/queryAll")
    Observable<SosContact> getAllContact(@Query("uid") String token);

    @POST("https://api.le-young.com/pushServer/api/sos/delete")
    Observable<SosContact> deleteContact(@Query("id") String token);

    @POST("https://api.le-young.com/pushServer/api/sos/update")
    Observable<SosContact> editContact(@Query("id") String token, @Query("uid") String uid, @Query("uname") String uName, @Query("phone") String phone, @Query("remake") String remake);

    @POST("https://api.le-young.com/pushServer/api/sos/add")
    Observable<SosContact> addContact(@Query("uid") String uid, @Query("uname") String uName, @Query("phone") String phone, @Query("remake") String remake);

    @POST("https://api.le-young.com/pushServer/api/sos/sos")
    Observable<SosContact> sendSos(@Query("uid") String uid, @Query("lat") String lat, @Query("lng") String lng);

    @GET("user/queryActivate")
    Observable<NetResultData<UserInfoQuery>> activateQuery(@Query("uid") String token);

    @Multipart
    @POST("userInfo/avatar")
    Observable<NetResultData<String>> updateIcon(@Part MultipartBody.Part file, @PartMap Map<String, RequestBody> map);

    @GET("https://app.le-young.com/jcloud/jclifedata/rank/activity/day")
    Observable<RankData> getRank(@QueryMap Map<String, Object> userMap);

    @GET("https://app.le-young.com/jcloud/jclifedata/rank/activity/month")
    Observable<RankData> getTotalRank(@QueryMap Map<String, Object> userMap);

}
